﻿using System;
using System.Collections.Generic;

namespace Cut
{
    public class Detail : Size, ISizes, IComparer<Detail>, IComparable<Detail>
    {
        public Detail(int width, int height)
        {
            Width = width;
            Height = height;
        }
        
        public int GetSquare()
        {
            return Height * Width;
        }

        public int GetSquareByBlock(Detail detail)
        {
            return (Width / detail.Width) * (Height / detail.Height);
        }

        public int Compare(Detail x, Detail y)
        {
            if (x.GetSquare() < y.GetSquare()) return 1;
            if (x.GetSquare() > y.GetSquare()) return -1;
            return 0;
        }

        public int CompareTo(Detail other)
        {
            return Compare(this, other);
        }
    }
}
